package controllers

import (
	"read.com/admin/models"
)

type BookratingController struct {
	BaseController
}

func (self *BookratingController) List() {
	self.Data["pageTitle"] = "评论管理"
	self.display()
}

func (self *BookratingController) Table() {
	isConfirm,_ := self.GetInt8("confirm")
	name := self.GetString("name")

	//列表参数
	page, err := self.GetInt("page")
	if err != nil {
		page = 1
	}
	limit, err := self.GetInt("limit")
	if err != nil {
		limit = 10
	}
	result,total := models.GetRecCommentList(isConfirm,name,page,limit)
	self.ajaxList("成功", MSG_OK, int64(total), result)
}

func (self *BookratingController) Check() {
	id,_ := self.GetInt("id")
	err := models.UpdateIsConfirmById(id)
	if err != nil {
		self.ajaxMsg("审核失败", MSG_ERR)
	}else {
		self.ajaxMsg("审核成功", MSG_OK)
	}
}

func (self *BookratingController) Del() {
	id,_ := self.GetInt("id")
	err := models.DelById(id)
	if err != nil {
		self.ajaxMsg("删除失败", MSG_ERR)
	}else {
		self.ajaxMsg("删除成功", MSG_OK)
	}
}
